package cc.catface.api.biz;

import cc.catface.common.aspect.NetLog;
import cc.catface.common.output.Result;
import cc.catface.dao.biz.app.ApUser;
import cc.catface.dao.biz.app.dto.*;
import cc.catface.service.ApUserServiceImpl;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@ApiSupport(order = 10)
@Api(tags = "[ap]用户")
@RestController
@RequestMapping("ap/user")
public class ApUserController {
    @Autowired
    private ApUserServiceImpl apUserService;

    @ApiOperationSupport(order = 10)
    @NetLog("注册")
    @ApiOperation(value = "注册=开发完成")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = RegistOUTDTO.class))
    @PostMapping("regist")
    public Result<RegistOUTDTO> regist(@RequestBody RegistINDTO in) {
        return apUserService.regist(in);
    }


    @ApiOperationSupport(order = 20)
    @NetLog("登录")
    @ApiOperation(value = "登录=开发完成")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = LoginOUTDTO.class))
    @PostMapping("login")
    public Result<LoginOUTDTO> login(@RequestBody LoginINDTO in) {
        return apUserService.login(in);
    }

    @ApiOperationSupport(order = 30)
    @NetLog("更新个人信息")
    @ApiOperation(value = "更新个人信息=开发完成")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = UpdateInfoOUTDTO.class))
    @PostMapping("updateInfo")
    public Result<UpdateInfoOUTDTO> updateInfo(@RequestBody UpdateInfoINDTO in) {
        return apUserService.updateInfo(in);
    }

    @ApiOperationSupport(order = 40)
    @NetLog("查个人信息")
    @ApiOperation(value = "查个人信息=开发完成")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = ApUser.class))
    @PostMapping("info")
    public Result<ApUser> info(@RequestBody InfoINDTO in) {
        return apUserService.info(in);
    }

    @ApiOperationSupport(order = 50)
    @NetLog("保存用户频道")
    @ApiOperation(value = "保存用户频道=开发完成", notes = "排序ord按由小到大排序")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = SaveUserChannelOUTDTO.class))
    @PostMapping("saveUserChannel")
    public Result<SaveUserChannelOUTDTO> saveUserChannel(@RequestBody SaveUserChannelINDTO in) {
        return apUserService.saveUserChannel(in);
    }

    @ApiOperationSupport(order = 60)
    @NetLog("查用户频道")
    @ApiOperation(value = "查用户频道=开发完成", notes = "排序ord按由小到大排序")
    @ApiResponses(@ApiResponse(code = 200, message = "Success", response = GetUserChannelOUTDTO.class))
    @PostMapping("getUserChannel")
    public Result<List<GetUserChannelOUTDTO>> getUserChannel(@RequestBody GetUserChannelINDTO in) {
        return apUserService.getUserChannel(in);
    }

}
